package com.xcity.game.task.detector;

import com.alibaba.fastjson.JSONObject;
import com.xcity.game.task.Task;
import com.xcity.game.task.TaskDetector;
import com.xcity.game.task.TaskDetectorLabel;

/**
 * PVE精英关通关
 * 1个参数:
 * 1.次数
 * @author shipeng.zhu
 */
@TaskDetectorLabel(TaskDetector.PVE_HERO_COUNT)
public class PVEHeroTaskDetector implements TaskDetector {

	static final String KEY = String.valueOf(PVE_HERO_COUNT);
	
	@Override
	public boolean isFinish(Task task) {
		int n = task.getTemplate().getConditions()[0];
		return task.getArchive().getInteger(KEY) >= n;
	}

	@Override
	public void onArchive(Task task, Object... vals) {
		//{25: 精英通关次数}
		int count = (int) vals[0];
		JSONObject archive = task.getArchive();
		archive.put(KEY, archive.getIntValue(KEY) + count);
	}

}
